
<template>
  <div class="wai-modal">
    <div class="nei-modal">
      <Card icon="log-in" title="欢迎登录" :bordered="false">
        <div class="form-con">
          <div class="filter">
            <label for="">账号：</label>
            <Input
              v-model="useAcco"
              placeholder="请输入账号"
              style="width: 200px"
            />
          </div>
          <div class="filter">
            <label for="">密码：</label>
            <Input
              v-model="password"
              placeholder="请输入密码"
              style="width: 200px"
            />
          </div>
          <div class="filter">
            <Button type="primary" style="width: 300px" @click="toLogin"
              >登录</Button
            >
          </div>
        </div>
      </Card>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import store from '../../store'
export default {
  data() {
    return {
      useAcco: "",
      password: "",
    };
  },
  methods: {
    toLogin() {
      axios
        .post("/api/gym/user/login", {
          acco: this.useAcco,
          psw: this.password,
        })
        .then((res) => {
          if (res.data.status == 200) {
            store.commit("setToken",res.data.data)
            this.$router.push("/");
          }
        });
    },
  },
};
</script>

<style>
.filter {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.wai-modal {
  width: 100%;
  height: 100%;
  background-image: url("../../assets/images/login-bg.jpg");
  background-size: cover;
  background-position: center;
}
.nei-modal {
  position: absolute;
  right: 160px;
  top: 50%;
  transform: translateY(-60%);
  width: 300px;
}
.form-con {
  padding: 10px 0 0;
}
</style>
